(function($){
	$.fn.menu = function(settings){
		var el, activity;
		settings = jQuery.extend({
			speed		: 220,
			autostart	: 1
		}, settings);
		
		el = $(this);
		el.children("ul").parent("li").children("a").addClass("activeTab");
		el.children("ul").addClass("activeSubtab");
		activity = el.children("a.activeTab");
   
		activity.css({
			"background": "url("+settings.off+") no-repeat",
		});
		
		if(settings.autostart){
			$("#"+settings.id).children("ul").slideDown(settings.speed*1.4, function (){
				$(this).removeAttr("class");
				$(this).attr("class", "noActiveSubtab");	
				activity.parent("li#"+settings.id).children("a.activeTab").css({
				  	"background": "url("+settings.on+") no-repeat",
				});	
			});
		}
		
		//Click on the tab
		activity.click(function (){
			var click = $(this);
			//Other slide up
			activity.parent("li").children("ul").slideUp(settings.speed/1.2, function(){
				$(this).removeAttr("class");
				$(this).attr("class", "activeSubtab");
				activity.css({
				  	"background": "url("+settings.off+") no-repeat",
				});	
			});
			click.removeAttr("class");
			click.attr("class", "noActiveTab");
			click.parent("li").children("ul.activeSubtab").slideDown(settings.speed, function (){
				$(this).removeAttr("class");
				$(this).attr("class", "noActiveSubtab");
				click.css({
				  	"background": "url("+settings.on+") no-repeat",
			    });	
			});
			return false;
		});
	}
})(jQuery);
